package global

import (
	"github.com/redis/go-redis/v9"
	log "github.com/sirupsen/logrus"
	"gorm.io/gorm"
	"os"
	"sg-backend/model/user"
)

// Redis 默认redis连接池
var Redis *redis.Client

// DB 数据库
var DB *gorm.DB

// SLog 系统日志
var SLog *log.Logger

// BLog 业务上下文日志
var BLog *log.Entry

var LogFile *os.File

type AuthUserPayload struct {
	UserId      uint
	Username    string
	IsSuperuser bool
	IsActive    bool
	IsLock      bool
}

var AuthUser *AuthUserPayload

func SetAuthUser(user *user.User) {
	AuthUser = &AuthUserPayload{
		UserId:      user.Id,
		Username:    user.Username,
		IsSuperuser: user.IsSuperuser,
		IsActive:    user.IsActive,
	}
}
